<#include "/admin/inc/ctx.html">
<style type="text/css">
#menuContent{position: absolute;z-index: 1000;left: 170px;top: 70px;display: block;display: none;background: #f2f2f2;border: 1px solid #ccc;}
.ztreeSty{margin-top:0;overflow-y:scroll; width:180px;height:140px;}
</style>
<script type="text/javascript">
var roleId='${(pageForm.id)!}';
var setting = {
		async : {
			enable : true,
			url : ctx + "/admin/module/simpleNodes",
			autoParam : [ "id=parent_channel_id" ],
			otherParam: ["roleId", roleId,"open",true]
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		check : {
			enable : true,
			chkboxType: { "Y" : "ps", "N" : "s" }
		},
		callback:{
            onCheck:onCheck
        }
	};
$(document).ready(function(){
	$.fn.zTree.init($("#treeDiv",$.pdialog.getCurrent()), setting);
});
function onCheck(e,treeId,treeNode){
    var treeObj=$.fn.zTree.getZTreeObj("treeDiv");
    var nodes=treeObj.getCheckedNodes(true);
    var moduleIds="";
    var moduleNames="";
    for(var i=0;i<nodes.length;i++){
      moduleIds+=nodes[i].id + ",";
      moduleNames+=nodes[i].name + "_";
    }
    $("#moduleIds").val(moduleIds.substring(0, moduleIds.length-1));
}
</script>
<div class="pageContent">
	<form method="post" action="${ctx}/admin/role/authorize" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
		<input type="hidden" name="id" value="${(pageForm.id)! }" /> 
		<input type="hidden" name="moduleIds" id="moduleIds" value="${(pageForm.moduleIds)! }" />
		<div class="pageFormContent" layoutH="56">
			<ul id="treeDiv" class="ztree"></ul> 
		</div>
		<div class="formBar">
			<ul>
			    <@shiro.hasPermission name="admin:role:authorize">
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
				</@shiro.hasPermission>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>